class Solution(object):
    def validPalindrome(self, s):
        """
        :type s: str
        :rtype: bool
        """
        n = len(s)
        left = 0
        right = n - 1
        while left < right:
            if s[left] == s[right]:
                left += 1
                right -= 1
            else:
                break
        if left >= right:
            return True
        else:
            return s[left + 1: right + 1] == s[right: left: -1] or s[left: right] == (
                s[right - 1: left - 1: -1] if left > 0 else s[right - 1:: -1])


data = Solution()
s = "eccer"
print(data.validPalindrome(s))
